package 
{
	import flash.display.Sprite;
	import flash.events.*;
	import flash.net.*;
	import flash.utils.*;
	import flash.xml.XMLNode;

	public class BackEnd extends Sprite
	{
		private var originalXml:XML;
		private var urlLoader:URLLoader;
		private var profiles:XMLList;
		
		private var dictSet:Dictionary;
		
		private var setPosition:Set;
		private var setIndustry:Set;
		private var setSalary:Set;
		
		private var debugStr:String = "$BackEnd Debug String$";
		
		public function BackEnd(list:XMLList)
		{
			debugStr += list.length();
			
			profiles = list;
			
			dictSet = new Dictionary();
			dictSet["position"] = new Set();
			dictSet["field"] = new Set();
			dictSet["salary"] = new Set();
			
			// collect all job information to help layout
			for (var i:int = 0; i < profiles.length(); i++) {
				for (var j:int = 0; j < profiles[i].job.length(); j++) {
					var jb:Job = new Job(profiles[i].job[j].toString());
					
					dictSet["position"].push(jb.getPosition());
					dictSet["field"].push(jb.getField());
					dictSet["salary"].push(jb.getSalary());
				}
			}
		}
		
		public function getChildren():XMLList {
			return profiles;
		}
		
		public function getAll(fieldName:String):Array {
			return dictSet[fieldName].toArray();
		}
		
		public function getDebugString():String {
			return debugStr;
		}
		
		/*
		public function LoadXML(e:Event):void {
			profiles = new XML(e.target.data);
		}
		*/
		
	}
	
}